package com.example.demo.zp.aop;

import com.example.demo.zp.TraceProcess;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * Created by ZhangPing on 2018/2/10.
 */
@Component
@Aspect
public class TraceAspect {

    @Pointcut("@annotation(com.example.demo.zp.annotation.Trace)")// 定义注解类型的切点，只要方法上有该注解，都会匹配
    @Order(1)
    public void annotationPoint() {

    }

    @Around("annotationPoint()")
    public Object trace(ProceedingJoinPoint proceedingJoinPoint) {
        return TraceProcess.trace(proceedingJoinPoint);
    }
}
